﻿@model BlankMvc.Types.UserRegister

<div class="modal fade" id="modalRegisterForm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" data-backdrop="false">
    <div class="modal-dialog">
        @using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal modal-content", role = "form", id = "registerFormId" })) {
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Регистрация нового пользователя</h4>
            </div>
            <div class="modal-body">
                @Html.AntiForgeryToken()
                @Html.ValidationSummary(true)
                <div class="form-group">
                    @Html.LabelFor(m => m.UserName, new { @class = "col-md-4 control-label" })
                    <div class="col-lg-6">
                        @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.UserName)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.Email, new { @class = "col-md-4 control-label" })
                    <div class="col-lg-6">
                        @Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Email)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.Password, new { @class = "col-md-4 control-label" })
                    <div class="col-lg-6">
                        <div class="input-group ">
                            @Html.PasswordFor(m => m.Password, new { @class = "form-control pwd" })
                            <span class="input-group-btn">
                                <button class="btn btn-default reveal" type="button"><i class="glyphicon glyphicon-eye-open"></i></button>
                            </span>
                        </div>
                        @Html.ValidationMessageFor(m => m.Password)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-4 control-label" })
                    <div class="col-lg-6">
                        <div class="input-group ">
                            @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control pwd" })
                            <span class="input-group-btn">
                                <button class="btn btn-default reveal" type="button"><i class="glyphicon glyphicon-eye-open"></i></button>
                            </span>
                        </div>
                        @Html.ValidationMessageFor(m => m.ConfirmPassword)
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <input type="submit" class="btn btn-primary" value="Регистрация" />
                <button type="button" class="btn btn-default" data-dismiss="modal">Отмена</button>
            </div>
        }
    </div>
</div>
<script type="text/javascript">
    $('#modalRegisterForm').modal('show');
    $.validator.unobtrusive.parse($("#registerFormId"));

    $('#registerFormId .reveal').mousedown(function () {
        var inp = $(this).closest('.input-group').find('.pwd');
        inp.replaceWith(inp.clone().attr('type', 'text'));
    }).bind('mouseup mouseout', function () {
        var inp = $(this).closest('.input-group').find('.pwd');
        inp.replaceWith(inp.clone().attr('type', 'password'));
    });
</script>
